#include <pfcGlobal.h>
#include <wfcClient.h>
#include <uifcDefaultListeners.h>
#include <logger.h>
#include <wxyutils.h>
#include "main.h"

wfcStatus AutoIndex();
wfcStatus CleanIndex();

//程序入口
extern "C" int user_initialize(
    int argc,
    char *argv[],
    char *version[],
    char *build,
    wchar_t errbuf[80])
{
    string dllpath;
    GetDllPath(dllpath);
    initLogger(dllpath + "info.log", dllpath + "warn.log", dllpath + "error.log");

    pfcSession_ptr session = pfcGetProESession();
    try
    {
        pfcUICommand_ptr AutoIndex_com = CreateUICommand(session, "AutoIndex_com", new MycallbackClass(AutoIndex),
                                                         MSGFILE, "AutoIndex", "AutoIndex", "AutoIndex",
                                                         new MyActionAccess(pfcACCESS_AVAILABLE));
        //设置快捷键
        session->SetConfigOption("mapkey", "oai ~ Command `AutoIndex_com`;");
        pfcUICommand_ptr CleanIndex_com = CreateUICommand(session, "CleanIndex_com", new MycallbackClass(CleanIndex),
                                                          MSGFILE, "CleanIndex", "CleanIndex", "CleanIndex",
                                                          new MyActionAccess(pfcACCESS_AVAILABLE));
        //设置快捷键
        session->SetConfigOption("mapkey", "oci ~ Command `CleanIndex_com`;");
    }
    OTK_EXCEPTION_PRINT_LOG
    catch (const std::exception &e)
    {
        std::cerr << e.what() << '\n';
    }

    return 0;
}
//程序出口
extern "C" void user_terminate()
{
}
